The index( ) Function is used to return the first occurrence of an element in the List.
Let us say, we have a List that contains three names, 'Mohan', 'Kriti' and 'Salim'. And we want to find the location of 'Kriti'.
x = ["Mohan", "Kriti", "Salim"] y = x.index("Kriti") print("The position of Kriti is ",y)
So, in the above code we have created a 'List' and initialised to the variable 'x'.
Below is how the values are positioned in the List,
Now, if we see the above diagram, 'Kriti' resides at position/index '1'.
And the 'index( )' Function is used to find the position of 'Kriti'.
And we get the below output,